package com.lupan.classicsJava.jpa.domain;

import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;

/**
 * 说明：教师
 *
 * @author lupan
 * @version 2017/3/8 14:23
 */
@Entity
@Table(name="TEACHER")
public class Teacher extends BaseEntity {

    @Column(nullable = false)
    private String name;
    private String subject;

    @OneToMany(mappedBy = "teacher",targetEntity = Student.class)
    private Set<Student> students = new HashSet<>();

    @ManyToMany(targetEntity = Class.class, mappedBy = "teachers")
    private Set<Class> classes = new HashSet<>();

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSubject() {
        return subject;
    }

    public void setSubject(String subject) {
        this.subject = subject;
    }

    public Set<Student> getStudents() {
        return students;
    }

    public void setStudents(Set<Student> students) {
        this.students = students;
    }

    public Set<Class> getClasses() {
        return classes;
    }

    public void setClasses(Set<Class> classes) {
        this.classes = classes;
    }
}
